import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/pages/my/controller/user_info_ctr.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

///修改密码
class FixPhone extends GetView<UserInfoController> {
  const FixPhone({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<UserInfoController>(builder: (controller){
      return BasePage(
      title: "修改手机号",
      iconType: IconType.back,
      isShowPadding: true,
      children: [
         Container(
          padding: EdgeInsets.all(18.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              controller.step==1? Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const SizedBox(
                    child: Text("请完成以下认证"),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 10.w),
                    child: Text("请输入 ${controller.encodePhoneNumber} 收到的验证码"),
                  ),
                ],
              ):newPhone(),
              

              Container(
                margin: EdgeInsets.only(top: 15.w),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Container(
                      width: 180.w,
                      height: 40.h,
                      padding: EdgeInsets.only(top: 10.w),
                      color: Colors.white,
                      child: TextFormField(
                        controller: controller.vertifyTxtCtr,
                        decoration: descript("请输入手机验证码"),
                        textAlign: TextAlign.center,
                      ),
                    ),
                    SizedBox(
                      width: 120.w,
                      height: 38.h,
                      child: solidButton(backgroundColor: controller.buttonColor , controller.countdownTxt, () {
                        controller.sendVerfityCode();
                      },radius: 10),
                    )
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 30.w),
                child: solidButton("下一步", () {
                  controller.submit();
                },radius: 10),
              )
            ],
          ),
        )
      ],
    );
    });
  }


  /**
   * 输入新手机号
   */
  Widget newPhone(){
    return Container(
      margin: EdgeInsets.only(top: 10.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
                margin: EdgeInsets.only(bottom: 10.w),
                child: const Text("绑定新号码"),
              ),
              Container(
                padding: EdgeInsets.only(left: 10.w,top: 10.w,bottom: 10.w),
                color: Colors.white,
                child: TextFormField(
                        controller: controller.newPhoneTxt,
                        decoration: descript("请输入要绑定的手机号"),
                        textAlign: TextAlign.start,
                      ),
              ),
        ],
      ),
    );
  }
}
